import axios from 'axios'

const request = axios.create({
  baseURL: 'http://localhost:3001',
  timeout: 5000
})

request.interceptors.request.use(config => {
  return config
})

request.interceptors.response.use(
  res => {
    return res
  },
  err => {
    //温馨提示:某一天发请求,请求失败,请求失败的信息打印出来
    console.log(err.message)

    //终止Promise链
    return new Promise()
  }
)

export default request
